﻿@model DateTime?

@{
    string type = ViewData.ModelMetadata.AdditionalValues.ContainsKey("Type")
        ? Convert.ToString(ViewData.ModelMetadata.AdditionalValues["Type"])
        : "DatePicker";
}

<div class="sale-setup-label-container">@Html.LabelFor(m => m)</div>
<div class="sale-setup-input-container">
    @Html.TextBoxFor(m => m,
        new Dictionary<string, object> {
            { "data-bind", "value:" + TN_CMS.Framework.Helper.CommonHelper.GetFullHtmlFieldNameWithoutPrefix(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty)) },
            { "class", "date-time-picker" }
        })
</div>
<div style="clear:both;height:10px;font-size:0px"></div>

@switch (type)
{
    case "DatePicker":
<script type="text/javascript">
    $(function () {
        $("#@ViewData.TemplateInfo.GetFullHtmlFieldId(string.Empty)").datepicker({
            changeMonth: true,
            changeYear: true
        });
    });
</script>
        break;
    case "DateTimePicker":
<script type="text/javascript">
    $(function () {
        $("#@ViewData.TemplateInfo.GetFullHtmlFieldId(string.Empty)").datetimepicker({
            changeMonth: true,
            changeYear: true
        });
    });
</script>
        break;
    default:
        break;
}